package com.Sep_Five;


/**
 *
 */

public class Solution101 {

    public boolean isSymmetric(TreeNode root) {
        if (root==null) return true;
        return dfs(root.left,root.right);
    }

    public boolean dfs(TreeNode left,TreeNode right){
        if (left==null&&right==null)
            return true;
        if (left==null||right==null||left.val!= right.val)
        {
            return false;
        }
        return dfs(left.left,right.right)&&dfs(left.right,right.left);
    }


    public static class TreeNode {
        int val;
        public TreeNode left;
        public TreeNode right;

        TreeNode() {
        }

        public TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }

}
